
<template>
  <div class="contract">
    <el-form v-show="showSearch" ref="queryParams" :model="queryParams" size="small" :inline="true" label-width="110px">
      <el-form-item label="员工编号" prop="code">
        <el-input v-model="queryParams.code" placeholder="请输入员工编号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="员工姓名" prop="name">
        <el-input v-model="queryParams.name" placeholder="请输入员工姓名" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="证件号码" prop="cardNum">
        <el-input v-model="queryParams.cardNum" placeholder="请输入证件号码" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery('queryParams')">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="employeeList" stripe>
<!--      <el-table-column type="selection" width="55" align="center" />-->
      <el-table-column label="序号" type="index" align="center" />
      <el-table-column label="员工编号" prop="code" align="center" />
      <el-table-column label="员工姓名" align="center" prop="name" />
      <el-table-column label="身份证号" align="center" prop="cardNum" />
      <el-table-column label="年龄" align="center" prop="age" />
      <el-table-column label="性别" align="center" prop="sex" :formatter="sexFormatter" />
      <el-table-column label="学历" align="center" prop="education">
        <template slot-scope="scope">
          {{ getEduName(scope.row.education) }}
        </template>
      </el-table-column>
      <el-table-column label="户籍地址" align="center" prop="domicileAddress" />
      <el-table-column label="岗位" align="center" prop="job" />
      <el-table-column label="生效日期" align="center" prop="insuranceStart" />
      <el-table-column label="失效日期" align="center" prop="insuranceEnd" />
      <!--      <el-table-column label="审核拒绝原因" align="center" width="100" prop="refuseRemark"  :show-overflow-tooltip="true">-->
      <!--        <template slot-scope="score">-->
      <!--          <span>{{score.row.refuseRemark}}</span>-->
      <!--        </template>-->
      <!--      </el-table-column>-->
      <!--      <el-table-column label="删除状态" align="center" prop="delFlag" />-->
      <!--      <el-table-column label="参与付款情况" align="center" prop="paymentStatus" >-->
      <!--        <template slot-scope="scope">-->
      <!--          <span v-if="scope.row.paymentStatus == '0'">未参与付款</span>-->
      <!--          <span v-if="scope.row.paymentStatus == '1'">已参与付款</span>-->
      <!--        </template>-->
      <!--      </el-table-column>-->
      <!--      <el-table-column label="参与结算情况" align="center" prop="settlementStatus" >-->
      <!--        <template slot-scope="scope">-->
      <!--          <span v-if="scope.row.settlementStatus == '0'">未参与结算</span>-->
      <!--          <span v-if="scope.row.settlementStatus == '1'">已参与结算</span>-->
      <!--        </template>-->
      <!--      </el-table-column>-->
      <!--      <el-table-column label="备注" align="center" prop="remark" />-->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <!-- <template slot-scope="scope">
        </template> -->
      </el-table-column>
    </el-table>

    <!-- 分页 -->
    <div class="pagination">
      <el-pagination :current-page="currentPage" :page-sizes="pageSizes" :page-size="pageSize" :total="total" layout="total, sizes, prev, pager, next, jumper" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
    </div>
  </div>
</template>

<script>
import {
  // insuranceList,
  // backListGroup,
  // waitAudit,
  backList
  // employeeList
  // employeeProjectList
} from '@/api/insure'
import { getDictData } from '@/api/dict'
export default {
  name: 'BackDetail',
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 列表数据
      employeeList: [],
      // 学历
      eduList: [],
      // 弹出层标题
      title: '',
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        name: null,
        code: null,
        property: null,
        insuranceStart: null,
        insuranceEnd: null,
        cardType: null,
        cardNum: null,
        nation: null,
        age: null,
        sex: null,
        domicileType: null,
        education: null,
        companyId: null,
        mobilePhone: null,
        domicileAddress: null,
        status: null,
        job: null,
        category: null,
        contactAddress: null,
        agreementId: null,
        insucanceId: null,
        auditStatus: null
      },
      currentPage: 1, // 当前页
      pageSizes: [10, 20, 50], // 每页条数
      pageSize: 10, // 每页条数
      total: 0 // 总条数
    }
  },
  created() {
    if (this.$route.query.property) {
      this.queryParams.property = this.$route.query.property
    }
    if (this.$route.query.companyId) {
      this.queryParams.companyId = this.$route.query.companyId
    }
    if (this.$route.query.insuranceStart) {
      this.queryParams.insuranceMonth = this.$route.query.insuranceStart
    }
    if (this.$route.query.agreementId) {
      this.queryParams.agreementId = this.$route.query.agreementId
    }
    if (this.$route.query.insucanceId) {
      this.queryParams.insucanceId = this.$route.query.insucanceId
    }
    this.getList()
    this.getEduList()
  },
  methods: {
    getList() {
      this.loading = true
      backList(this.queryParams).then(response => {
        this.employeeList = response.rows
        this.total = response.total
        this.loading = false
      })
    },

    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery(formName) {
      this.$refs[formName].resetFields()
      this.handleQuery()
    },

    // 每页条数改变
    handleSizeChange(val) {
      this.queryParams.pageSize = val
      this.getList()
    },

    // 当前页改变
    handleCurrentChange(val) {
      this.queryParams.pageNum = val
      this.getList()
    },
    sexFormatter(row) {
      switch (row.sex) {
        case '0':
          return '男'
        case '1':
          return '女'
      }
    },
    getEduList() {
      const data = { 'dictType': 'education' }
      getDictData(data).then(response => {
        this.eduList = response.data
      })
    },

    getEduName(value) {
      const dict = this.eduList.find(item => item?.dictValue === value)
      if (dict) {
        return dict.dictLabel
      }
    }
  }
}

</script>

<style lang="scss" scoped>
.contract {
  padding: 20px;
  line-height: 1;

  .contract_filter {
    margin-bottom: 20px;
  }

  .pagination {
    margin-top: 20px;
    display: flex;
    justify-content: center;
  }
}
</style>
